import React from 'react';
import logo from './logo.svg';
import './App.css';
import {Button} from 'antd';
import {BrowserRouter as Router, Switch, Redirect, Link, Route} from "react-router-dom";
import {renderRoutes} from 'react-router-config';
import {adminRoutes} from './router/Router'
import Home from './views/Home'
import {isLogined} from "./utils/auth";

function App() {
    return isLogined() ? (
        <Home>
            <Switch>
                {adminRoutes.map(route => {
                    return (
                        <Route
                            key={route.path}
                            path={route.path}
                            exact={route.exact}
                            render={routeProps => {
                                return <route.component {...routeProps} />;
                            }}
                        />
                    );
                })}
                <Redirect to={adminRoutes[0].path} from="/admin" />
                <Redirect to="/error"/>
            </Switch>
        </Home>

    ): (
        <Redirect to="/login" />
    );
}

export default App;
